SearchPortlet = Class.extend({
	init: function()	{
		this.name = "SearchPortlet";
	},
	
	onBegin: function()	{
		this.registerObserver();
	},
	
	onEnd: function()	{
		this.unregisterObserver();
	},
	
	run: function()	{
		this.getPortletPlaceholder().paintCanvas(this.render());
	},
	
	onSearchProductKeyup: function(event)	{
		var key = event.keyCode;
		if (key == 13)	{
			var subject = SingletonFactory.getInstance(Subject);
			subject.notifyEvent('SearchProduct');
		}
	},
	
	onSearchProduct: function()	{
		//store the current object
		var obj = this;
		var key = this.requestForEffectiveResource('Key').val().trim();
		if (key == "")	{
			return;
		}
		var subject = SingletonFactory.getInstance(Subject);
		subject.notifyEvent('RequestRoute', new Request('Search', undefined, {key: key}));
//		this.onAjax('product', 'search-products', {key: key}, 'POST', {
//			'onSuccess': function(ret)	{
//				obj.model = {};
//				obj.model.result = ret.data;
//				obj.getPortletPlaceholder().paintCanvas(obj.render());
//			}
//		});
	}
}).implement(PortletInterface).implement(RenderInterface).implement(AjaxInterface).implement(ObserverInterface);